﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace POI.eTransmittal.WebApp.Usercontrols
{
    public partial class StatusControl : System.Web.UI.UserControl
    {
        public string haltAnchor = "false";
        private string _navigateUrl = string.Empty;
        protected void Page_Init(object sender, EventArgs e)
        {
           
            if (!IsPostBack)
            {
                if (Session["StatusMsg"] != null)
                {
                    haltAnchor = "true";
                }
            }

            if (Session["PaswdExpire"] != null)
            {
                haltAnchor = "true";
            }

        }

        protected void Page_Load(object sender, EventArgs e)
        {
            int status = 0;
            if (!IsPostBack)
            {
                if (Session["StatusMsg"] != null)
                {
                    SetStatusMessage(Session["StatusMsg"].ToString());
                    Session["StatusMsg"] = null;
                }
                status = 1;
            }
            if (Session["PaswdExpire"] == null)
            {
                pnlWarningMsg.ClientVisible = false;
            }
            else if (Session["PaswdExpire"] != null && status == 1)
            {
                ShowWarningMessage(Session["PaswdExpire"].ToString());
            }

        }

        public void SetNavigateUrl(string url)
        {
            //string closeUpScrip = "function(s, e) { window.location= '" + url + "'; /}";
            //pnlStatus.Attributes.Add("CloseUp", closeUpScrip);
          
            lblUrl.Text = url;
        }


        public void SetStatusMessage(string statusMsg)
        {
            lblStatus.Text = statusMsg;
            pnlStatus.ShowOnPageLoad = true;
            haltAnchor = "true";

        }
        public void HideLoading()
        {
            popcLoading.ShowOnPageLoad = false;
      
        }
        public void ShowErrorMessage(Exception exc)
        {
            lblMessage.Text = exc.Message;
            lblSource.Text = exc.ToString();
            pcErrorMessage.ShowOnPageLoad = true;
            haltAnchor = "true";

        }

        public void ShowErrorMessage(string errMsg)
        {
            lblMessage.Text = errMsg;
            pcErrorMessage.ShowOnPageLoad = true;
            pnlSource.Visible = false;
            linkSource.Visible = false;
        }

        public void ShowWarningMessage(string warnMsg)
        {
            lblWarning.Text = warnMsg;
            pnlWarningMsg.ClientVisible = true;
            linkWarnSource.ClientVisible = false;
            pnlWarnSource.ClientVisible = false;
        }
    }
}